# Contributor: Dylan Van Assche <me@dylanvanassche.be>
# Maintainer: Dylan Van Assche <me@dylanvanassche.be>
pkgname=obexd-enhanced
pkgver=5.79
pkgrel=0
pkgdesc="OBEXD with enhanced capabilities such as PBAP"
url="https://www.bluez.org/"
arch="all"
license="GPL-2.0-or-later"
depends="
	!bluez-obexd
	bluez~$pkgver
	dbus
	obex-capabilities
	"
makedepends="
	autoconf
	automake
	dbus-dev
	ell-dev
	eudev-dev
	evolution-data-server-dev
	glib-dev
	json-c-dev
	libical-dev
	libtool
	libusb-compat-dev
	linux-headers
	py3-docutils
	py3-pygments
	readline-dev
	"
source="https://www.kernel.org/pub/linux/bluetooth/bluez-$pkgver.tar.xz
	org.bluez.obex.service
	001-bcm43xx-Add-bcm43xx-3wire-variant.patch
	002-bcm43xx-The-UART-speed-must-be-reset-after-the-firmw.patch
	003-Increase-firmware-load-timeout-to-30s.patch
	004-Move-the-43xx-firmware-into-lib-firmware.patch
	005-hostname-Use-phone-class-for-handhelds.patch
	disable-lock-test.patch
	fix-endianness.patch
	test-mesh-crypto.patch
	disable-test-vcp.patch
	gdbus-define-MAX_INPUT-for-musl.patch
	"

builddir="$srcdir/bluez-$pkgver"

provides="obexd=$pkgver-r$pkgrel"
replaces="obex-capabilities<=0.2.1-r4"

# secfixes:
#   5.54-r0:
#     - CVE-2020-0556

prepare() {
	default_prepare

	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--libexecdir=/usr/lib \
		--disable-systemd \
		--with-phonebook=ebook \
		--with-dbusconfdir=/usr/share
	make
}

check() {
	make check
}

package() {
	mkdir "$builddir/bluez"
	mkdir -p "$pkgdir"/usr/lib/bluetooth

	make install DESTDIR="$builddir/bluez"

	mv "$builddir"/bluez/usr/lib/bluetooth/obexd "$pkgdir"/usr/lib/bluetooth

	install -Dm644 "$srcdir"/org.bluez.obex.service \
		"$pkgdir"/usr/share/dbus-1/services/org.bluez.obex.service
}

sha512sums="
74d47b1eb9b9904798f5c8093674743a14a509d22c33003cf253a1ab0c11a564e6a10a808e087e3fb7f3589d3cba1868ec9bf2923703cdc36a293c95af1d0d76  bluez-5.79.tar.xz
6b53966522df8405f4cfb794874dc2f126abded53fddf1fd559126afc039faab9d51421852dba8abf53700fd79388db16897d590151fe6a43f97676f868d08ee  org.bluez.obex.service
73202915fda01d420b2864da77b1c25af5a55c815e9be6546400a0940bfb6097d83322790bc22a80ec0fcd557144fdd1877e243a79285a7f040ff96ba3600b94  001-bcm43xx-Add-bcm43xx-3wire-variant.patch
d5fd1c962bd846eaa6fff879bab85f753eb367d514f82d133b5d3242e1da989af5eddd942c60a87d5b67783e060f91bfa0f74fb1e8e6699cdee6e5bbe6a431ea  002-bcm43xx-The-UART-speed-must-be-reset-after-the-firmw.patch
784e9644c8de4e2693e2eeed988a245608b8cb14e1fc0dff8795c60c527b2e8d0c87862cfbfd6b850b47ae80cdf993a5ed3f477078ea1068fd7374899c7a1a77  003-Increase-firmware-load-timeout-to-30s.patch
6d864d893aaf08d7a04f5cb27a6b2767c361cd41e479f27ed84d9fbbd2677298c15e31161a614af098df8faf3da54b71cf315fe8e9a9a2f671e4720c7b8b457b  004-Move-the-43xx-firmware-into-lib-firmware.patch
ac635f9bca0e983835940572eb1b96ad70cf60fb84d5b0fde38c76ea6d1b13ef7d9adf81468b9fed779c890ab69dd5dfabf21970bff018466115c424668b82fb  005-hostname-Use-phone-class-for-handhelds.patch
04c4889372c8e790bb338dde7ffa76dc32fcf7370025c71b9184fcf17fd01ade4a6613d84d648303af3bbc54043ad489f29fc0cd4679ec8c9029dcb846d7e026  disable-lock-test.patch
2f54da5e77893d1d8b7164ddac5561a9e536c2b93b1d33dcbd97e74c0fd45588f1f50dc1d9d8519297871e3a376948082a2e45e27d823ec81cdedecd8dba3f0c  fix-endianness.patch
b5d6f7d2df755a9b8cffaeef13d232ba1bab27544bc59e2299bbd6a8017768cf7781f3ca65e430a149a26f0b30ae74b8510529ce161705bb6f41ae512cc2dbac  test-mesh-crypto.patch
e7a07f26d92caaf11a457a8504219973da0aa80f2c97b36af2135aa36f7f4b52978f632c9c5123d66d71b4b65a780710dea802ca0dcaabc5c051f7b7d21763cf  disable-test-vcp.patch
5dbbae8193987abaf8db982435aeac9ba6f69e5491d5c553985fce13d5b548929c0a363341a45708ea7e6d7dc656d6d9c3f4669ab860ea038df43c29f2b70796  gdbus-define-MAX_INPUT-for-musl.patch
"
